//
// ObjectARX defined commands

#include "StdAfx.h"
#include "StdArx.h"

#include "site.h"
#include "zone.h"
#include "pipe.h"
#include "Branch.h"
#include "navigationmanager.h"
#include "AddObjectCommand.h"
#include "EditObjectCommand.h"
#include "DeleteObjectCommand.h"
#include "OpenProjectCommand.h"
#include "NewProjectCommand.h"
#include "SetCurConfigrationCommand.h"
#include "CloseProjectCommand.h"
#include "SaveProjectCommand.h"
#include "Spec.h"
#include "Spco.h"
#include "spwl.h"
#include "sele.h"
//test
#include "Application.h"
#include "Project.h"


using namespace PDMS::COMMAND;
extern NavigationManager* GetMember();

// This is command 'ADDZONE'
void UEUESOFTAddZONE()
{
	AddObjectCommand<Zone> e;
	e.Execute();

}

// This is command 'SHOW'
void UEUESOFTSHOWD()
{
	if(Application::Instance()->ActiveProject() == NULL)
	{
		CString strTemp = "";
		strTemp.LoadString(IDC_WARRING_NOPROJECT);
		AfxMessageBox(strTemp);
		return;
	}
	GetMember()->Show(FALSE);

}

// This is command 'ADDSITE'
void UEUESOFTADDSITE()
{
	AddObjectCommand<Site> e;
	e.Execute();

}

// This is command 'ADDPIPE'
void UEUESOFTADDPIPE()
{
	AddObjectCommand<Pipe> e;
	e.Execute();

}

// This is command 'EDIT'
void UEUESOFTEdit()
{
	EditObjectCommand e;
	e.Execute();

}


// This is command 'DELETEOBJECT'
void UEUESOFTDeleteObject()
{
	DeleteObjectCommand e;
	e.Execute();

}

// This is command 'ADDBRANCH'
void UEUESOFTAddBranch()
{
	AddObjectCommand<Branch> e;
	e.Execute();

}

// This is command 'OPENPROJECT'
void UEUESOFTOpenProject()
{
	OpenProjectCommand e;
	e.Execute();

}

// This is command 'NEWPROJECT'
void UEUESOFTNEWPROJECT()
{
	NewProjectCommand e;
	e.Execute();

}

// This is command 'SETCONFIG'
void UEUESOFTSETCONFIG()
{
	SetCurConfigrationCommand e;
	e.Execute();

}

// This is command 'CLOSEPROJECT'
void UEUESOFTCloseProject()
{
	CloseProjectCommand e;
	e.Execute();

}

// This is command 'SAVEPROJECT'
void UEUESOFTSaveProject()
{
	SaveProjectCommand e;
	e.Execute();

}

// This is command 'ADDMOUNTOBJECT'
void UEUESOFTAddMountObject()
{
	UeDbObject* pRoot = NULL;
	Application::Instance()->ActiveProject()
		->GetCurDatabase()->TreeModel( pRoot );
	Site* newSite = NULL;
	for( int i = 0; i < 20; i++ )
	{		
		newSite = new Site;
		StdString strTemp = "";

		strTemp.Format("%d",i);
		strTemp += "OfSite";

		newSite->Name( strTemp );
		pRoot->Add(newSite);

		for(int j = 0; j < 20; j++)
		{
			UeDbObject* pZone = new Zone;
			StdString strZone = "";
			strZone.Format("%d+%d",i,j);
			strZone += "Zone";
			pZone->Name(strZone);
			newSite->Add(pZone);		
			pZone->Close();

		}
		newSite->Close();
		newSite = NULL;
	}
	ActiveObjectListener curObject( pRoot->Id() );
	pRoot->Close();
	GetMember()->Updata();
	

}

using namespace PDMS::SpecFrame;

// This is command 'ADDSPWL'
void ueuesoftaddspwl()
{
	AddObjectCommand<Spwl> command;
	command.Execute();

}

// This is command 'ADDSPEC'
void ueuesoftaddspec()
{
	AddObjectCommand<Spec> command;
	command.Execute();

}

// This is command 'ADDSELE'
void ueuesoftaddsele()
{
	AddObjectCommand<Sele> command;
	command.Execute();

}

// This is command 'ADDSPCO'
void ueuesoftaddspco()
{
	AddObjectCommand<Spco> command;
	command.Execute();

}

